package com.kou.backend.controller.user;

import com.kou.backend.api.user.IUserLoginClient;
import com.kou.backend.request.login.UserLoginReqDTO;
import com.kou.backend.resposne.ResultResponse;
import com.kou.backend.resposne.login.UserLoginResponseDTO;
import com.kou.backend.service.UserLoginService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import jakarta.servlet.http.HttpServletRequest;

/**
 * 用户登录controller
 *
 * @author: Chaojie.Kou
 * @since: 2023/8/30 16:08
 */
@Slf4j
@RestController
public class UserLoginController implements IUserLoginClient {
    @Resource
    private UserLoginService userLoginService;

    @Override
    public ResultResponse<UserLoginResponseDTO> login(UserLoginReqDTO userLoginReqDTO, HttpServletRequest request) {
        log.info("用户:****{}****登录", userLoginReqDTO.getUserAccount());
        UserLoginResponseDTO responseDTO = userLoginService.login(userLoginReqDTO);
        log.info("用户:*****{}****登录成功", userLoginReqDTO.getUserAccount());
        return ResultResponse.success(responseDTO);
    }

    @Override
    public ResultResponse<Object> logout() {
        return ResultResponse.success();
    }
}
